{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. Run ado.file\n",
    "``betterbar`` produces bar graphs with grouping of variables, standard error bars, and cross-group comparisons."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "qui do \"https://raw.githubusercontent.com/worldbank/Stata-IE-Visual-Library/develop/Library/Bar%20plots/Horizontal%20bar%20plot%20with%20betterbar%20ado%20file/betterbar.ado\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. Upload data (.dta)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "use \"https://github.com/worldbank/Stata-IE-Visual-Library/raw/develop/Library/Bar%20plots/Horizontal%20bar%20plot%20with%20betterbar%20ado%20file/data.dta\", clear"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. Create the graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(25 real changes made)\n",
      "(24 real changes made)\n"
     ]
    }
   ],
   "source": [
    "betterbar ///\n",
    "\t\t( sp1_h1 sp1_h2 sp1_h3 sp1_h4 sp1_h5 sp1_h7 sp1_h8 sp1_h9 sp1_h10 sp1_h11 sp1_h12 sp1_h13 sp1_h14 sp1_h15 sp1_h16 sp1_h17 sp1_h18 sp1_h19 sp1_h20 sp1_h21 ) ///\n",
    "\t\t( sp1_e1 sp1_e2 sp1_e3 sp1_e5 sp1_e6 ) ///\n",
    "\t\t, d(1) xlab(0 \"0%\" .25 \"25%\" .5 \"50%\" .75 \"75%\" 1 \"100%\") barl(mean) barlook(1 fc(black) lc(black))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4. Export the graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(file figure.png written in PNG format)\n"
     ]
    }
   ],
   "source": [
    "graph export \"figure.png\" , width(4000) replace"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Stata",
   "language": "stata",
   "name": "stata"
  },
  "language_info": {
   "file_extension": ".do",
   "mimetype": "text/x-stata",
   "name": "stata"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
